package com.chennan.rebbitmq.leading.consumer;



import com.rabbitmq.client.Channel;
import org.springframework.amqp.support.AmqpHeaders;

import org.springframework.cloud.stream.annotation.StreamListener;

import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * @author chennan
 * @createTime 2021年07月08日 17:02:00
 */
//@Service
public class MyConsumerInputImpl {

    @StreamListener(value = MyStreamClient.DATA_TO_RABBITMQ_BOOK_INPUT)
    public void excelExportSlow(@Header(AmqpHeaders.CHANNEL) Channel acknowledgment,
                                @Payload String exportConditionDTO,
                                @Header(AmqpHeaders.DELIVERY_TAG) Long deliveryTag) throws IOException {
        System.out.println("接受到了消息！！！！"+deliveryTag+exportConditionDTO);
        try {
            TimeUnit.SECONDS.sleep(deliveryTag.intValue());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //未ack 默认30分钟推送一次
        acknowledgment.basicAck(deliveryTag,false);
        System.out.println("进行了手动ack！！！！");
    }

}
